package com.questionnaires.repository;

import com.questionnaires.exception.EmptyListException;
import com.questionnaires.exception.NotExistsException;
import com.questionnaires.model.Category;
import com.questionnaires.model.Questionnaire;
import com.questionnaires.model.User;

import java.util.List;

/**
 * Interface for the repository that handles questionnaire operations.
 *
 * @author adriana.calina.oros@gmail.com
 */
public interface QuestionnaireRepository {

    /**
     * Creates or updates a questionnaire
     *
     * @param questionnaire the questionnaire to be processed.
     */
    long saveOrUpdate(Questionnaire questionnaire);

    /**
     * Deletes the questionnaire with the specified id
     *
     * @param id questionnaire's id
     * @throws NotExistsException thrown when no questionnaire exists with this id
     */
    void delete(long id) throws NotExistsException;

    /**
     * Retrieves all questionnaires from database.
     *
     * @return a list of all questionnaires from database
     */
    List<Questionnaire> getAll();

    Questionnaire findById(long id);

    /**
     * Retrieves the active questionnaires from a specified category
     *
     * @param category the specified category
     * @return the list of questionnaires from the specified category
     * @throws NotExistsException if there are no questionnaires in that category
     */
    List<Questionnaire> findActiveQuestionnairesByCategory(Category category) throws EmptyListException;

    /**
     * Retrieves the questionnaires of a manager from a specified category
     *
     * @param manager  the specified manager
     * @return the list of manager's questionnaires from a specified category
     * @throws NotExistsException if no questionnaires are found
     */
    List<Questionnaire> findByManager(User manager) throws EmptyListException;

    void setInactive(long id) throws NotExistsException;

}
